package com.bdqn.carrental.controller;

import com.bdqn.carrental.dao.CustomersMapper;
import com.bdqn.carrental.pojo.Customers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

@RestController
@RequestMapping("/customer")
public class CustomersController {
    @Autowired
    CustomersMapper customersMapper;

    /**
     * 用户登录
     * @param username 用户名
     * @param password 用户密码
     * @return 用户实体类
     */
    @RequestMapping("/login")
    public Object Login(
            @RequestParam(value = "username",required =false)String username,
            @RequestParam(value = "password",required =false)String password){
        System.out.println(username + "--" + password);

        //若没传参则返回员工登录页面
        if(username ==null || "".equals(username)){
            ModelAndView mv = new ModelAndView("login");
            return mv;
        }
        Customers customers=customersMapper.findByIdentityAndCustpwd(username,password);
        return customers;
    }


}
